import 'package:flutter/material.dart';

class MyApp3 extends StatefulWidget {
  const MyApp3({super.key});

  @override
  State<MyApp3> createState() => _MyApp3State();
}

class _MyApp3State extends State<MyApp3> {
  String name = '张三';
  int age = 20;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // 这里fontSize的单位和鸿蒙中的vp类似，在不同的设备上显示不同的大小
        title: Text(
          'Flutter初体验',
          style: TextStyle(color: Colors.white, fontSize: 20),
        ),
        backgroundColor: Colors.pink,
        centerTitle: true,
      ),
      body: Center(
        child: Text('我叫$name，今年$age岁了。', style: TextStyle(fontSize: 25)),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            name = name + '!';
            age = age + 1;
          });
          print(age);
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}
